home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks95
/
Aaron 1.0b3.sit
/
Aaron 1.0b3
/
Aaron Source
/
CDEF and Patches
/
DrawTitle.c
< prev
next >
Wrap
Text File
|
1995-06-24
|
3KB
|
111 lines
/* Aaron © 1995 Gregory D. Landweber, ALL RIGHTS RESERVED */
#include "CDEF.h"
#include <Icons.h>
void GrayForeColor ( short index );
void DrawTitle ( GregInfo *theInfo, Boolean embossed, Boolean pushed, Boolean invert )
{
FontInfo fontProperties;
short lineHeight, nLines, baseLine, firstChar, chIndex, lineLength, x, y;
RgnHandle oldClip, newClip;
short length;
StringPtr theTitle;
unsigned char newTitle[4];
Rect theRect;
if ( theInfo->newFolder ) {
theTitle = newTitle;
SetRect (&theRect, theInfo->theRect.right - 27,
( theInfo->theRect.bottom + theInfo->theRect.top - 16 ) >> 1,
theInfo->theRect.right - 11,
( theInfo->theRect.bottom + theInfo->theRect.top + 16 ) >> 1 );
if ( pushed && !theInfo->inActive )
OffsetRect (&theRect, 1, 1);
if ( theInfo->inActive )
PlotIconID (&theRect, atVerticalCenter, 1, -3999);
else
PlotIconID (&theRect, atVerticalCenter, 0, -3999);
*(long *)theTitle = ' New';
theTitle[0] = 3;
}
else {
HLock ( (Handle) theInfo->theControl );
theTitle = (*(theInfo->theControl))->contrlTitle;
}
oldClip = NewRgn ();
GetClip (oldClip);
newClip = NewRgn ();
RectRgn( newClip, &(theInfo->theRect) );
SectRgn ( newClip, oldClip, newClip);
SetClip ( newClip );
if ( embossed )
GrayForeColor ( 0x0F );
else
GrayForeColor ( 0x00 );
if ( invert )
GrayForeColor ( 0x0F );
if ( theInfo->inActive )
TextMode (grayishTextOr);
else
TextMode (srcOr);
GetFontInfo( &fontProperties );
lineHeight = fontProperties.ascent + fontProperties.descent + fontProperties.leading;
length = theTitle[0];
nLines = 1;
for (chIndex = 1; chIndex <= length; chIndex++)
if ( theTitle[chIndex] == 13 )
nLines += 1;
baseLine = theInfo->theRect.bottom -
(theInfo->theRect.bottom + 1 - theInfo->theRect.top - nLines * lineHeight) / 2
- fontProperties.leading - fontProperties.descent - (nLines - 1) * lineHeight;
if ( theInfo->pushButton && (lineHeight < 13) )
baseLine--;
firstChar = 1;
for (chIndex = 1; chIndex <= length; chIndex++)
if ( ( theTitle[chIndex] == 13 ) ||
( chIndex == length ) ) {
lineLength = chIndex - firstChar;
if ( chIndex == length )
lineLength += 1;
y = baseLine;
if ( !theInfo->pushButton )
x = theInfo->theRect.left + ButtonLeft + ButtonSize + TitleGap;
else {
if ( theInfo->newFolder )
x = theInfo->theRect.left + 14;
else
x = ( theInfo->theRect.left + theInfo->theRect.right -
TextWidth ( theTitle, firstChar, lineLength ) ) / 2;
if ( pushed && !theInfo->inActive ) {
x++;
y++;
}
if ( embossed ) {
x++;
y++;
}
}
MoveTo (x, y);
DrawText( theTitle, firstChar, lineLength);
baseLine = baseLine + lineHeight;
firstChar = chIndex + 1;
}
SetClip (oldClip);
DisposeRgn (oldClip);
DisposeRgn (newClip);
if ( !theInfo->newFolder )
HUnlock ( (Handle) theInfo->theControl );
}